package com.campus.service.impl;

import com.campus.dao.ActivityDao;
import com.campus.model.Activity;
import com.campus.service.ActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class ActivityServiceImpl implements ActivityService {

    @Autowired
    private ActivityDao activityDao; // 注入 DAO 实例

    @Override
    public int createActivity(Activity activity) {
        // 创建活动时设置默认状态为已创建（0）
        activity.setStatus(0);
        return activityDao.createActivity(activity);
    }

    @Override
    public boolean updateActivity(Activity activity) {
        // 调用 DAO 更新活动信息
        return activityDao.updateActivity(activity) > 0;
    }

    @Override
    public boolean publishActivity(int activityId) {
        // 调用 DAO 发布活动
        return activityDao.publishActivity(activityId) > 0;
    }

    @Override
    public List<Activity> queryActivities(Integer status, String name, String orderBy) {
        // 调用 DAO 查询活动列表
        return activityDao.queryActivities(status, name, orderBy);
    }

    @Override
    public List<Activity> listAllActivities() {
        return activityDao.findAllActivities();
    }

    @Override
    public boolean deleteActivity(int id) {
        return activityDao.deleteActivity(id);
    }

}
